package com.krtech.wecard.module.mayi.controller;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.krtech.wecard.module.mayi.entity.MayiCommentSay;
import com.krtech.wecard.module.mayi.entity.MayiLiuliang;
import com.krtech.wecard.module.mayi.entity.MayiMachineManageCount;
import com.krtech.wecard.module.mayi.service.MayiCommentSayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/mayiCommentSay")
@Slf4j
@Api(value = "蚂蚁评论语录管理")
public class MayiCommentSayController {

    @Autowired
    private MayiCommentSayService commentSayService;

    @GetMapping("/save")
    @ApiOperation(value = "save")
    public boolean save(String say){
        MayiCommentSay commentSay = new MayiCommentSay();
        commentSay.setCreatedTime(new Date());
        commentSay.setContent(say);
        return commentSayService.save(commentSay);
    }

    @GetMapping("/page")
    @ApiOperation(value = "page")
    public Page<MayiCommentSay> page(Page<MayiCommentSay> page, String keyword) {
        QueryWrapper<MayiCommentSay> wrapper = new QueryWrapper<>();
        if (StrUtil.isNotEmpty(keyword)){
            wrapper.like(MayiCommentSay.COL_CONTENT,keyword);
        }
        return commentSayService.page(page,wrapper);
    }

    @GetMapping("/deleteById")
    @ApiOperation(value = "deleteById")
    public boolean page(Integer id){
        return commentSayService.removeById(id);
    }
}